package CB_C19;

import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Alert.*;

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;

//Layout

/**Sector for "Framedrop ON/OFF"*/
var enable      : HBox;
 /**Sector for other Effet elements in GUI*/
public var effect_vbox : HBox;

//Controls duration + Begin

/**displays "Duration(s)"*/
var duration_text       : Label;
/**displays "Begin(s)"*/
var begin_text          : Label;
/**when checked, GUI elements for the effect are enabled
 * @defaultvalue false
 */
public var enable_effect    : CheckBox;
/**allows input in seconds
 * @defaultvalue 0
 */
public var duration     : TextBox;
/**allows input in seconds
 * @defaultvalue 0
 */
public var begin        : TextBox;

//Button return properties + reset properties

/**effect settings are applied to the video*/
var submit              : Button;
/**resets all effect settings to their default values*/
var reset               : Button;

/**Effect Created on 10.11.2009. <br>
 * <br>
 * Represents the effects(duration and beginn)<br>
 * Function :  <br>
 * 1) Enable the effects.<br>
 * 2) reset all effects<br>
 * 3) inform value of all effects<br>
 * @author Sebastian Czekierski, Stefan Blumberger
 */
public class gui_Effect extends CustomNode
{
    override function create(): Node
    {
        return Group
        {
            content:
            [
               enable = HBox
               {
                   translateX: 0;
                   content: enable_effect = CheckBox
                   {
                            text: "Framedrop ON/OFF";
                            allowTriState: false;
                            selected: false;
                   }
               }
               effect_vbox = HBox
               {
                   translateX: enable.width + enable.translateX + 20;
                   disable: bind not(enable_effect.selected);
                   visible: bind not(Main.class_brightness.checkBox.selected);
                   content:
                   [
                       duration = TextBox
                       {
                           translateX: 0;
                           text: "10"
                           columns: 3
                       }
                       duration_text = Label
                       {
                           translateX: 10;
                           translateY: 5;
                           text: "Duration(s)";
                       }
                       begin = TextBox
                       {
                           translateX: 30;
                           text: "0"
                           columns: 3
                       }
                       begin_text = Label
                       {
                           translateX: 40;
                           translateY: 5;
                           text: "Begin(s)";
                       }
                       submit = Button
                       {
                           translateX: 50;
                           text: "Print_Properties";
                           action:function()
                           {
                                var effect_param:String;
                                effect_param = "Duration(s): {duration.text} \n";
                                effect_param += "Begin(s): {begin.text}\n";
                                effect_param += "Brightness: {Main.class_brightness.brightness.value as Integer}\n";
                                effect_param += "Strength(frames): {Main.class_strength.frames.value as Integer}\n";
                                effect_param += "Random: {Main.class_strength.random.selected}";
                                inform("Effect_Parameter: ",effect_param,);

                           }
                       }
                       reset = Button
                       {
                            translateX: submit.translateX + 5 ;
                            text: "Reset";
                            action:function()
                            {
                                Main.class_brightness.brightness.value = 100;
                                Main.class_strength.frames.value = 0;
                                Main.class_strength.random.selected = false;
                                Main.class_effect.duration.text = "0";
                                Main.class_effect.begin.text = "0";
                            }
                       }
                   ]
           }
            ]
        };
    }
}

